import { HttpException, HttpStatus } from '@nestjs/common';
import { ErrorCode } from '../constants/error-code.enum';
import { ErrorMessage } from '../constants/error-message.enum';

export class BusinessException extends HttpException {
  constructor(code: ErrorCode, message?: string) {
    super(
      {
        code,
        message: message || ErrorMessage[code],
      },
      HttpStatus.OK, // 业务异常通常使用200状态码，通过code区分错误类型
    );
  }
} 